$(function () {

    var itemIndex = 0;
	var indexct = 1;
	var page = 1;
    var tabLoadEndArray = [false, false, false];
    var tabLenghtArray = [28, 15, 47];
    var tabScroolTopArray = [0, 0, 0];
    
    // dropload
    var dropload = $('.khfxWarp').dropload({
        scrollArea: window,
        domDown: {
            domClass: 'dropload-down',
            domRefresh: '<div class="dropload-refresh">上拉加载更多</div>',
            domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
            domNoData: '<div class="dropload-noData">已无数据</div>'
        },
        loadDownFn: function (me) {
            setTimeout(function () {
                if (tabLoadEndArray[itemIndex]) {
                    me.resetload();
                    me.lock();
                    me.noData();
                    me.resetload();
                    return;
                }
                var result = '';
                //奖励细则
                $.getJSON(path + '/wx/c/judgesion/oneandTowadvisorJsonPage.html?page=' + page +'&leve=' + leve, function (data) {
                    //遍历json中的每个entry
                	var isHasData = 0;
                	result = '';

                	//业绩奖励
                    $.each(data, function (entryindex, entry) {                   	
                        result
                        = ''
                        + '<li><i>'+encodeMobile(entry['mobile'])+'</i><b>'+entry['createDate']+'</b></li>';
                        isHasData = 1;
                        $('#advisorList').append(result);  	
                    });
                    page++;
                    if(isHasData == 0)
                    {
                        tabLoadEndArray[itemIndex] = true;
                        
                    }	
                    me.resetload();
                });                  
              //邀请奖励
            }, 500);
        }
    });

    function encodeMobile(mobile)
    {
    	
    	return mobile.substring(0,3)+"****"+mobile.substring(8,11);;  
    }
    $('.tabHead span').on('click', function () {

        tabScroolTopArray[itemIndex] = $(window).scrollTop();
        var $this = $(this);
        itemIndex = $this.index();
        $(window).scrollTop(tabScroolTopArray[itemIndex]);
        
        $(this).addClass('active').siblings('.tabHead span').removeClass('active');
        $('.tabHead .border').css('left', $(this).offset().left + 'px');
        $('.khfxPane').eq(itemIndex).show().siblings('.khfxPane').hide();

        if (!tabLoadEndArray[itemIndex]) {
            dropload.unlock();
            dropload.noData(false);
        } else {
            dropload.lock('down');
            dropload.noData();
        }
        dropload.resetload();
    });
});